/*
 *  auth : panweiguo@58.com
 *  date : 2015-07-27
 *  decoraction : 
 */
define(function() {
	var common = {
		// 每3位数字加上,分隔
		numFormat : function(num) {
			var str = (typeof(num) === 'number') ? num.toString() : num;
			if (str.indexOf('.') > -1) {
				var docNum = str.split('.')[1];
				str = str.split('.')[0];
			}
			var remainder = str.length % 3;

			var newStr = [];

			if (remainder != 0) {
				newStr.push(str.substr(0,remainder));
			}
			for ( var i = 0, l = (str.length-remainder)/3; i < l; i++ ) {
				newStr.push(str.substr(remainder+3*i, 3));
			}

			return docNum ? newStr.join(',')+'.'+docNum : newStr.join(',');
		},
		minToHour : function(minute) {
			var num = (typeof(minute) === 'number') ? minute : parseInt(minute);
			var hour = Math.floor(num/60), min = num%60;
			hour = hour < 10 ? '0'+hour.toString() : hour.toString();
			min = min < 10 ? '0'+min.toString() : min.toString();
			return hour + ':' + min;
		},
		timeToHour  : function(time) {
			time = (typeof(time) === 'number') ? time : parseInt(time);
			var theDate = new Date();
			theDate.setTime(time);
			var hour = theDate.getHours() < 10 ? '0'+theDate.getHours().toString() : theDate.getHours().toString();
			var minute = theDate.getMinutes() < 10 ? '0'+theDate.getMinutes().toString() : theDate.getMinutes().toString();
			return hour+':'+minute;
		}
	}

	return common;
})